package com.origin.tingting.domain;

import org.junit.Test;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author： 丁涛
 * @Date: Created in 18:00 2019/2/14
 * @Description: ${description}
 * @Version: ${version}
 */
public class GenSql {
    @Test
    public void generator() throws Exception{
        List<String> warnings = new ArrayList<>();
        String path = getClass().getClassLoader().getResource("").getPath();
        System.out.println("path:"+path);
        String[] list = path.split("/");
        ArrayList<String> arrayList = new ArrayList<>(Arrays.asList(list));
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.println((i+1)+arrayList.get(i));
        }
//        strList.remove(0);
        arrayList.remove(list.length-1);
        String newPath = "";
        for (String s : arrayList) {
            newPath+=s;
            newPath+="/";
        }
        System.out.println(newPath);
//        File configFile = new File("E:\\IdeaProProject\\tingting\\src\\main\\resources\\generatorConfig.xml");
        File configFile = new File(".generatorConfig.xml");
        System.out.println();
        System.out.println(configFile.exists());
//        ConfigurationParser cp = new ConfigurationParser(warnings);
//        Configuration config = cp.parseConfiguration(configFile);
//
//        DefaultShellCallback callback = new DefaultShellCallback(true);
//        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
//        myBatisGenerator.generate(null);
    }
    public void function(){

//        do something
        if (true){
//            do something
        }
        else{
//            do something
        }
    }
    public void function1(){

//        do A
        if (true){
//            do A
        }
        else{
//            do A
        }
    }

    public void function2(){

//        do B
        if (true){
//            do B
        }
        else{
//            不do
        }
    }
}
